import { getConfig } from 'src/utils';
import { DataSource } from 'typeorm';
const { MYSQL_CONFIG } = getConfig();

// 提供数据库实例
export const DatabaseProviders = [
  {
    provide: 'DATABASE_CONNECTION',
    useFactory: async () =>
      await new DataSource({
        ...MYSQL_CONFIG, //载入数据库配置
        entities: [__dirname + '/../../**/*.entity.{js,ts}'], //动态引入entity类
      }).initialize(),
  },
];
